***************************************************************
* This script reproduces all Stata results
* Run this script before replication.R
* Before running, set working directory to the project's folder
* Results are based on Stata 18
***************************************************************

* set Stata version
*version 18

* install additional packages if needed
*ssc install estout

****************************************************************
* Coefficient Plots of First Difference Estimates
****************************************************************

* Incumbent
use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22)) | (party == "SVP" & cod_prov == 21)
keep if damaged_prov_binary == 1 
keep if cod_reg != 3

xtset pro_com anno
gen diffshare=party_share-l5.party_s

reg diffsh i.damage_binary i.cod_pro if anno == 2019, cluster(SLL)
reg diffsh i.damage_binary i.cod_pro if anno == 2014, cluster(SLL)
reg diffsh i.damage_binary i.cod_pro if anno == 2009, cluster(SLL)

keep pro_com anno diffsh damage* cod_pro SLL

saveold "FD_incumbent.dta", version(12) replace

* Greens
use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if party == "green" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
keep if anno == 2004 | anno == 2014 | anno == 2019

bys pro_com (anno): gen year = _n
xtset pro_com year
gen diffshare=party_share-l.party_s

reg diffsh i.damage_binary i.cod_pro if anno == 2019, cluster(SLL)
reg diffsh i.damage_binary i.cod_pro if anno == 2014, cluster(SLL)

keep pro_com anno diffsh damage* cod_pro SLL

saveold "FD_greens.dta", version(12) replace

* M5S
use "vaia.dta", clear
keep if party == "M5S" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
keep if anno == 2014 | anno == 2019

xtset pro_com anno

gen diffshare=party_share-l5.party_s

reg diffsh i.damage_binary i.cod_pro if anno == 2019, cluster(SLL)

keep pro_com anno diffsh damage* cod_pro SLL

saveold "FD_M5S.dta", version(12) replace

****************************************************************
* Event Study Plot of TWFE, IPW-TWFE, and Placebo Estimates
****************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22)) | (party == "SVP" & cod_prov == 21)
keep if anno == 2004 | anno == 2009 | anno == 2014 | anno == 2019

keep if damaged_prov_binary == 1 
keep if cod_reg != 3

xtset pro_com anno

gen logalt = log(mean_altitude+1)

logit damage_binary logalt income_ind_2017 pop_tot_1jan18 forest_perc pop_dens18 foreign_share_1jan18 if anno == 2019 
predict pscore

* gen placebo treatment variable
psmatch2 damage_binary if anno == 2019, pscore(pscore) outcome(party_share) common
bys pro_com: egen _w  = max(_weight)
drop _weight
gen placebo = 0 if damage_binary == 0
replace placebo = 1 if _w!= . & damage_binary == 0
drop _w

* gen IPW for full sample
sum pscore if damage_binary == 1 & anno == 2019
sum pscore if damage_binary == 0 & anno == 2019
gen support = 0 if anno == 2019
replace support = 1 if pscore >= .0341655 & pscore <= .7150978
gen w_IPW = .
replace w_IPW = 1/pscore if damage_binary == 1 & anno == 2019
replace w_IPW = 1/(1-pscore) if damage_binary == 0 & support == 1 & anno == 2019
bys pro_com: egen _ipw  = max(w_IPW)
drop w_IPW


* estimates
eststo: xtreg party_share damage_binary##i.anno, fe cl(SLL)
eststo:	xtreg party_share damage_binary##i.anno [aw=_ipw], fe cl(SLL)
eststo: xtreg party_share i.placebo##i.anno i.anno, fe cl(SLL)

* export to R
keep pro_com SLL_2011 anno party_share placebo damage_binary _ipw pscore
rename _ipw ipw

save "placebo_vaia.dta", replace

***************************************************************
* Interaction with Disaster Relief (Exclude Bolzano)
***************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22))
keep if damaged_prov_binary == 1 
keep if cod_reg != 3

xtset pro_com anno

egen fondi_std = std(fondi_wgtd)
gen fondi_std_t = fondi_std
replace fondi_std_t = 0 if anno < 2019

est clear

rename damage_binary_t Damaged
eststo: xtreg party_share i.Damaged c.fondi_std##i.anno i.cod_prov##i.anno, fe cl(SLL)
eststo: xtreg party_share i.Damaged##c.fondi_std c.fondi_std##i.anno i.cod_prov##i.anno, fe cl(SLL)
rename Damaged damage_binary_t

rename damage_mean_t Damaged
eststo: xtreg party_share c.Damaged c.fondi_std##i.anno i.cod_prov##i.anno, fe cl(SLL) 
eststo: xtreg party_share c.Damaged##c.fondi_std c.fondi_std##i.anno i.cod_prov##i.anno, fe cl(SLL)
rename Damaged damage_mean_t

rename damage_max_t Damaged
eststo: xtreg party_share c.Damaged c.fondi_std##i.anno i.cod_prov##i.anno, fe cl(SLL)
eststo: xtreg party_share c.Damaged##c.fondi_std c.fondi_std##i.anno i.cod_prov##i.anno, fe cl(SLL)
rename Damaged damage_max_t

esttab using "table1_interaction_fondi.tex", replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(year_fe municipality_fe prov_trend ymean N r2 measure,  fmt(0 2))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


************************************************************
* Table of Pre-post DID Estimates on vote for Regional Incumbent
************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22)) | (party == "SVP" & cod_prov == 21)
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
xtset pro_com anno

est clear

gen Damaged_2019 = 0
replace Damaged_2019 = damage_mean if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_mean if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_mean if anno == 2004
eststo: xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)

drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_max if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_max if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_max if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_binary if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_binary if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

esttab using "ax-tab_main_results_incumbent.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*******************************************************
*  Table of Pre-post DID Estimates on vote for the Green
*******************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if party == "green" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
keep if anno == 2004 | anno == 2014 | anno == 2019
xtset pro_com anno

est clear

gen Damaged_2019 = 0
replace Damaged_2019 = damage_mean if anno == 2019
gen Damaged_2004 = 0
replace Damaged_2004 = damage_mean if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_max if anno == 2019
gen Damaged_2004 = 0
replace Damaged_2004 = damage_max if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
gen Damaged_2004 = 0
replace Damaged_2004 = damage_binary if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2004

esttab using "ax-tab_main_results_green.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*************************************************************
*  Table of Pre-post DID Estimates on Vote for Five Star Movement
*************************************************************

use "vaia.dta", clear
keep if party == "M5S" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
keep if anno == 2014 | anno == 2019

xtset pro_com anno

est clear

gen Damaged_2019 = 0
replace Damaged_2019 = damage_mean if anno == 2019
eststo: xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019

gen Damaged_2019 = 0
replace Damaged_2019 = damage_max if anno == 2019
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
eststo: xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019

esttab using "ax-tab_main_results_m5s.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

**************************************************************
* Table of Pre-post DID Estimates on Vote for Mainstream Parties
**************************************************************

* Forza Italia
use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if party == "FI" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
xtset pro_com anno

est clear

gen Damaged_2019 = 0
replace Damaged_2019 = damage_mean if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_mean if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_mean if anno == 2004
eststo:	    xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_max if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_max if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_max if anno == 2004
eststo:	    xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_binary if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_binary if anno == 2004
eststo:	    xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

* PD
use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if party == "PD" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
xtset pro_com anno

gen Damaged_2019 = 0
replace Damaged_2019 = damage_mean if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_mean if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_mean if anno == 2004
eststo:	    xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_max if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_max if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_max if anno == 2004
eststo:	    xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_binary if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_binary if anno == 2004
eststo:	    xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

esttab using "ax-tab_did_pd_fi.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


***************************************************************
* Plot of Trends in Raw Means of Vote Share by Treatment Group
***************************************************************

* Incumbent
use "vaia.dta", clear

keep if anno == 2004 | anno == 2009 | anno == 2014 | anno == 2019
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22)) | (party == "SVP" & cod_prov == 21)
keep if damaged_prov_binary == 1 
keep if cod_reg != 3

collapse (mean) party_share (semean) se=party_share, by(anno damage_binary)

gen per = party_share*100
gen cilo = per-1.96 * se*100
gen cihi = per+1.96 * se*100

rename anno year
rename damage_binary damaged

keep year damaged per cilo cihi

save "parallel_incumbent_damage.dta", replace


* Green
use "vaia.dta", clear

keep if anno == 2004 | anno == 2014 | anno == 2019 
keep if tipo_elezione == "europea"
keep if party == "green" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3

collapse (mean) party_share (semean) se=party_share, by(anno damage_binary)

gen per = party_share*100
gen cilo = per-1.96 * se*100
gen cihi = per+1.96 * se*100

rename anno year
rename damage_binary damaged

keep year damaged per cilo cihi

save "parallel_green_damage.dta", replace

* M5S
use "vaia.dta", clear

keep if anno == 2014 | anno == 2019
keep if tipo_elezione == "europea"
keep if party == "M5S" 
keep if damaged_prov_binary == 1 
keep if cod_reg != 3

collapse (mean) party_share (semean) se=party_share, by(anno damage_binary)

gen per = party_share*100
gen cilo = per-1.96 * se*100
gen cihi = per+1.96 * se*100

rename anno year
rename damage_binary damaged

keep year damaged per cilo cihi

save "parallel_m5s_damage.dta", replace


******************************************************
* Table of Dose Response Estimates 
******************************************************

use "vaia.dta", clear

keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22)) | (party == "SVP" & cod_prov == 21)

keep if damaged_prov_binary == 1 
keep if cod_reg != 3

xtset pro_com anno

xtile damage_mean_tiles_t = damage_mean if anno == 2019 & damage_binary == 1, n(3)
xtile damage_max_tiles_t = damage_max if anno == 2019 & damage_binary == 1, n(3)

replace damage_mean_tiles_t = 0 if anno != 2019 | damage_binary != 1
replace damage_max_tiles_t = 0 if anno != 2019  | damage_binary != 1
 
est clear

rename damage_mean_tiles_t Damaged_t
eststo:	xtreg party_share i.Damaged_t  i.anno##i.cod_prov, fe cl(SLL_2011)
rename Damaged_t damage_mean_tiles_t 

rename damage_max_tiles_t Damaged_t
eststo:	xtreg party_share i.Damaged_t  i.anno##i.cod_prov, fe cl(SLL_2011)
rename Damaged_t damage_max_tiles_t 

esttab using "ax-tab_dose_response.tex", keep(*.Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


***************************************************************
* Table of Covariate Balance Before and After IPW
***************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22)) | (party == "SVP" & cod_prov == 21)
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
keep if anno == 2019

gen logalt = log(mean_altitude+1)

logit damage_binary logalt income_ind_2017 pop_tot_1jan18 forest_perc pop_dens18 foreign_share_1jan18 if anno == 2019 
predict pscore

* Gen IPW
sum pscore if damage_binary == 1 & anno == 2019
sum pscore if damage_binary == 0 & anno == 2019
gen support = 0 if anno == 2019
replace support = 1 if pscore >= .0341655 & pscore <= .7150978
gen w_IPW = .
replace w_IPW = 1/pscore if damage_binary == 1 & anno == 2019
replace w_IPW = 1/(1-pscore) if damage_binary == 0 & support == 1 & anno == 2019
bys pro_com: egen _ipw  = max(w_IPW)
drop w_IPW

rename damage_binary treated

* Balance table
matrix table = J(6, 10, .) 

local i = 1
foreach var of varlist logalt income_ind_2017 pop_tot_1jan18 forest_perc pop_dens18 foreign_share_1jan18 {

    summarize `var' if treated == 0
    matrix table[`i', 1] = r(mean)
    matrix table[`i', 2] = r(sd)

    summarize `var' if treated == 1
    matrix table[`i', 3] = r(mean)
    matrix table[`i', 4] = r(sd)

    quietly reg `var' treated
    matrix table[`i', 5] = _b[treated]


    local t = _b[treated] / _se[treated]
    local p = 2 * ttail(e(df_r), abs(`t'))
    matrix table[`i', 6] = `t'
    matrix table[`i', 7] = `p'

    quietly reg `var' treated [aw = _ipw]
    matrix table[`i', 8] = _b[treated]

    local t_w = _b[treated] / _se[treated]
    local p_w = 2 * ttail(e(df_r), abs(`t_w'))
    matrix table[`i', 9] = `t_w'
    matrix table[`i', 10] = `p_w'

    local i = `i' + 1
}

* Sample stats
summarize logalt income_ind_2017 pop_tot_1jan18 forest_perc pop_dens18 foreign_share_1jan18 
matrix table[6, 1] = r(mean)
matrix table[6, 2] = r(sd)

* Set number format
forval j = 1/6 {
    forval k = 1/10 {
        matrix table[`j', `k'] = round(table[`j', `k'], 0.01)
    }
}

* Set column names
matrix colnames table = Mean_Group0 SD_Group0 Mean_Group1 SD_Group1 Coeff_NoWeights Tstat_NoWeights P-Value_NoWeights Coeff_Weights Tstat_Weights P-Value_Weights
matrix rownames table = logalt income_ind_2017 pop_tot_1jan18 forest_perc pop_dens18 foreign_share_1jan18 

* Export
label var pop_tot_1jan18 "Population (2018)"
label var foreign_share_1jan18 "Foreigners (\%, 2018)"
label var income_ind_2017 "Average Income (2017)"
label var logalt "Mean Altitude (log)"
label var forest_perc "Forest area (\%, 2010)"
label var pop_dens18 "Population density (2018)"

estout matrix(table) using "ax-tab_balance.tex", replace style(tex) label cells(fmt(%9.2fc))

*****************************************************************
* Table of Pre-Post DID Estimates Aggregating by Labor Market Area
*****************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22))  | (party == "SVP" & cod_prov == 21)
keep if damaged_prov_binary == 1 
keep if cod_reg != 3

collapse (mean) party_share damage_mean_t damage_max_t  (max) damage_binary_t, by(SLL_2011 anno)

xtset SLL_2011 anno

est clear

gen Damaged_2019 = damage_mean_t
eststo: xtreg party_share Damaged_2019 i.anno, fe cl(SLL)
drop Damaged_2019

gen Damaged_2019 = damage_max_t
eststo: xtreg party_share Damaged_2019 i.anno, fe cl(SLL)
drop Damaged_2019

gen Damaged_2019 = damage_binary_t
eststo:	xtreg party_share Damaged_2019 i.anno, fe cl(SLL)
drop Damaged_2019

esttab using "ax-tab_spillover_incumbent.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

****************************************************************
* Table of Pre-post DID Estimates Dropping Bolzano
****************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22))
keep if damaged_prov_binary == 1 
keep if cod_reg != 3
xtset pro_com anno

est clear

gen Damaged_2019 = 0
replace Damaged_2019 = damage_mean if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_mean if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_mean if anno == 2004
eststo: xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_max if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_max if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_max if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
gen Damaged_2009 = 0
replace Damaged_2009 = damage_binary if anno == 2009
gen Damaged_2004 = 0
replace Damaged_2004 = damage_binary if anno == 2004
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov if anno > 2009, fe cl(SLL)
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
eststo: xtreg party_share Damaged_2019 Damaged_2009 Damaged_2004 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019 Damaged_2009 Damaged_2004

esttab using "ax-tab_results_without_Bolzano.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

****************************************************************
* Table of Pre-Post DID Estimates Including Moderately Affected Provinces (Lombardia)
****************************************************************

use "vaia.dta", clear
keep if tipo_elezione == "europea"
keep if (party == "LN" & (cod_reg == 3 | cod_reg == 5 | cod_reg == 6 | cod_prov == 22))  | (party == "SVP" & cod_prov == 21)
keep if damaged_prov_binary == 1 
xtset pro_com anno

est clear

gen Damaged_2019 = 0
replace Damaged_2019 = damage_fraction if anno == 2019
eststo: xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019

gen Damaged_2019 = 0
replace Damaged_2019 = damage_binary if anno == 2019
eststo:	xtreg party_share Damaged_2019 i.anno i.anno##i.cod_prov, fe cl(SLL)
drop Damaged_2019

esttab using "ax-tab_did_lombardia.tex", keep(Damaged_*)  replace b(%8.3f) se(%8.3f) noomitted nobaselev stats(N,  fmt(0 0))  star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

